/**
 *	flowauto
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2023-07-31
 */

package com.framework.Module.flow.flowauth;



import com.framerock.db.DB;
import com.framerock.baselib.Json;
import com.framerock.baselib.Rock;
import com.framework.Flow.FlowListener;
import com.framework.Model.ModelMode;

import java.util.ArrayList;
import java.util.Map;

public class FlowListenerflowauth extends FlowListener {


    public Boolean onModejs() {
        return true;
    }

    @Override
    public Boolean onRemind() { return false; }


    @Override
    public Boolean onisAdd() {
        return true;
    }

    @Override
    public Boolean onisEdit() {
        return true;
    }

    public Map<String, String> onDataafter()
    {
        Map<String, String> da = Rock.getMap();
        if(mRequest.LOADCI==1){
            String where = "`isxt`=2";
            if(mRequest.COMPANYBOOL){
                String inwhere = DB.dbSql(DB.chuliPerfix("flowunit"), "modeid", "`cid`="+mRequest.COMPANYID+" AND `modeid`>0");
                where += " AND `id` IN("+inwhere+")";
            }
            ArrayList<Map<String, String>> rows = ModelMode.get(this.nDb).getMdearr("(("+where+") OR `num`='usera')");
            da.put("modearr", Json.getListString(rows));
        }

        return da;
    }

    public Map<String, String> onDatabefore(){
        String where  = "";
        int modeid = Integer.parseInt(mRequest.get("modeid", "0"));
        if(modeid>0)where  = "`modeid`="+modeid+"";
        return Rock.getMap(new String[]{
                "where", where
        });
    }
}
